import Vue from 'vue';
import Vuex from 'vuex';
import chat from './module/chat';
import { CURRENT_USER_KEY, TOKEN_key } from '../util/misc';
import { USER_ORIENTED } from '../util/config';
import { TESTING } from '../util/test';

Vue.use(Vuex);

const getters = {};

const mutations = {
  changeProlist(state, val) {
    state.prolist = val;
  },
  changeUser(state, val) {
    state.user = val;
  },
  changeToken(state, val) {
    state.token = val;
  },
};

export default new Vuex.Store({
  state: {
    // 一般这里放全局都需要用的数据
    user: uni.getStorageSync("currentUser") || {},
    token: uni.getStorageSync("token") || '',
    // 省市区列表
    prolist: [],
    userOriented: USER_ORIENTED, // 用户端还是招商端
    TESTING: TESTING,
  },
  mutations,
  modules: { chat },
  getters,
});
